var roleFighter = {

    /** @param {Creep} creep **/
    run: function(creep) {
        //creep.say('AFKclr I', true);

        // var enemys = creep.room.find(FIND_HOSTILE_CREEPS);
        // var enemystructure = creep.room.find(FIND_HOSTILE_STRUCTURES, {
        //     filter: (structure) => (structure.structureType != STRUCTURE_CONTROLLER )
        // });
        // if(creep.attack(enemys[0]) == ERR_NOT_IN_RANGE) {
        //     //creep.say('123');
        //     creep.moveTo(enemys[0], {visualizePathStyle: {stroke: '#ffaa00'}});
        // }
        // else if(creep.attack(enemystructure[0]) == ERR_NOT_IN_RANGE) {
        //     //creep.say('123');
        //     creep.moveTo(enemystructure[0], {visualizePathStyle: {stroke: '#ffaa00'}});
        // }
        // else
        // {
        //     //creep.say('123');
        //     creep.moveTo(Game.flags['Flag8'].pos);
        // }

        var enemys = creep.room.find(FIND_HOSTILE_CREEPS);
        var enemystructure = creep.room.find(FIND_HOSTILE_STRUCTURES
        , {
            filter: (structure) => (
                structure.structureType != STRUCTURE_CONTROLLER 
            && structure.structureType != STRUCTURE_RAMPART
            )
        }
        );
        if(enemys.length>0) {
            creep.say('emy');
            creep.moveTo(enemys[0], {visualizePathStyle: {stroke: '#ffaa00'}});
            creep.attack(enemys[0]);
        }
        else if(enemystructure.length>0) {
            creep.say('str');
            creep.moveTo(enemystructure[0], {visualizePathStyle: {stroke: '#ffaa00'}});
            creep.attack(enemystructure[0]);
        }
        //手动攻击目标
        //else if(creep.room.find(Game.getObjectById('610023843485b4597374cd29'))){
//creep.moveTo(Game.getObjectById('610023843485b4597374cd29'), {visualizePathStyle: {stroke: '#00ff00'}});
           // creep.attack(Game.getObjectById('610023843485b4597374cd29'));
        //}
        else
        {
            creep.say('on the way');
            creep.moveTo(Game.flags['E8S57'].pos, {visualizePathStyle: {stroke: '#00ff00'}});
        }


	}
};

module.exports = roleFighter;